import axios from '../utils/http'
// 过滤掉params中cb函数
function filterParams(params:any){
    for(let key in params){
        if(typeof params[key]==='function'){
            delete params[key]
        }
    }
    return params
}

export const request=(apiUrl,params:any={},type:string='post',)=>{
    params=filterParams(params)
    if(type==='post'){
        return axios.post(apiUrl,params)
    }else{
        return axios.get(apiUrl,params)
    }
}